/**
 * fulihui.com Inc.
 * Copyright (c) 2015-2016 All Rights Reserved.
 */
package com.fulihui.weixinsdk.request.news;

import com.alibaba.fastjson.JSON;
import com.fulihui.weixinsdk.http.HttpMethodEnum;
import com.fulihui.weixinsdk.request.WeixinRequest;
import com.fulihui.weixinsdk.result.news.NewsStatResult;
import com.google.gson.Gson;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;
import java.util.TreeMap;

/**
 * 获取图文群发总数据（getarticletotal）
 *
 * @author: Levon
 * @date: 2018-07-25 09:56
 */
@Data
public class NewsArticletotalRequest extends WeixinRequest<NewsStatResult> {

    private transient String access_token;
    private String begin_date;
    private String end_date;

    @Override
    public Map<String, String> urlParam() {
        Map<String, String> param = new TreeMap<>();
        if (StringUtils.isNotBlank(access_token)) {
            param.put("access_token", access_token);
        }
        return param;
    }

    @Override
    protected void childParam() {

    }

    @Override
    public String service() {
        return "https://api.weixin.qq.com/datacube/getarticletotal";
    }

    @Override
    public String urlEndStr() {
        return null;
    }

    @Override
    public NewsStatResult parseResult(String respStr) {
        return new Gson().fromJson(respStr, NewsStatResult.class);
    }

    @Override
    public HttpMethodEnum httpMethod() {
        return HttpMethodEnum.POST;
    }

    @Override
    public String requestData() {
        return JSON.toJSONString(this);
    }
}
